var server_url = "http://www.ipl-2008.com"

function getProfilePic(objPerson)
{
 pic = objPerson.getField(opensocial.Person.Field.THUMBNAIL_URL) ;
		 if (pic == null || pic == "" || pic.indexOf('null') != -1 || pic.indexOf('nophoto') != -1)
		 {
		  pic = orkut_url + "/img/i_nophoto64.gif";
		 }
 return pic ;		 
}

function getTimeStamp()
{
	var currdate = new Date();
	var stamp = currdate.getYear() + currdate.getMonth() + currdate.getDate() + currdate.getHours() + currdate.getMinutes() + currdate.getSeconds() ;
	return stamp ;
}

function submitUserdata(gender,country,profile_url)
{
	var params = {}; 
	var postdata = {
    user_id : objViewer.getId(),
    user_gender : gender,
	user_country : country,
	user_profile_url : profile_url,
	display_name : objViewer.getDisplayName(),
	th_url : getProfilePic(objViewer),
	ts : getTimeStamp()
  };
	params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED;
	params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT; 
	params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
    params[gadgets.io.RequestParameters.POST_DATA] = gadgets.io.encodeValues(postdata);
	var url = server_url + '/ring_builder/submituserdata.php'
	//var url = 'http://orkut.games2win.com/submituserdata.php'
	gadgets.io.makeRequest(url, function(response){}, params);
}

function getCreatedRings()
{
	var params = {}; 
	var postdata = {
    user_id : objViewer.getId(),
	start_id : start_id,
	ts : getTimeStamp()
  };
	params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED;
	params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT; 
	params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
    params[gadgets.io.RequestParameters.POST_DATA] = gadgets.io.encodeValues(postdata);
	var url = server_url + '/ring_builder/submituserdata.php'
	//var url = 'http://orkut.games2win.com/submituserdata.php'
	gadgets.io.makeRequest(url, showCreatedRings, params);
}

function getReceivedRings()
{
	var params = {}; 
	var postdata = {
    user_id : objViewer.getId(),
	start_id : start_id,
	ts : getTimeStamp()
  };
	params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED;
	params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT; 
	params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
    params[gadgets.io.RequestParameters.POST_DATA] = gadgets.io.encodeValues(postdata);
	var url = server_url + '/ring_builder/submituserdata.php'
	//var url = 'http://orkut.games2win.com/submituserdata.php'
	gadgets.io.makeRequest(url, showReceivedRings, params);
}

function getTopRings()
{
	var params = {}; 
	var postdata = {
    user_id : objViewer.getId(),
	start_id : start_id,
	ts : getTimeStamp()
  };
	params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED;
	params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT; 
	params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
    params[gadgets.io.RequestParameters.POST_DATA] = gadgets.io.encodeValues(postdata);
	var url = server_url + '/ring_builder/submituserdata.php'
	//var url = 'http://orkut.games2win.com/submituserdata.php'
	gadgets.io.makeRequest(url, showTopRings, params);
}
